<?php if(!defined('HDPHP_PATH'))exit;C('SHOW_NOTICE',FALSE);?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>无标题文档</title>
		<link href="http://127.0.0.1/vancl/Static/Admin/css/style.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="http://127.0.0.1/vancl/Static/hdjs/hdjs.min.js"></script>
		<link rel="stylesheet" type="text/css" href="http://127.0.0.1/vancl/Static/hdjs/hdjs.css"/>
		
		<script type="text/javascript" src="http://127.0.0.1/vancl/Static/uploadify/jquery-1.8.2.min.js"></script>
		<script type="text/javascript" src="http://127.0.0.1/vancl/Static/uploadify/jquery.uploadify.min.js"></script>
		<link rel="stylesheet" type="text/css" href="http://127.0.0.1/vancl/Static/uploadify/uploadify.css" />

		<?php if(!defined('HDPHP_PATH'))exit;C('SHOW_NOTICE',FALSE);?>
		<style type="text/css">
			#uploadList ul li{
				list-style: none;
				float: left;
				margin-right: 10px;
				position: relative;
				border: 1px solid #CCC;
			}
			#a_del_li img{
				position: absolute;
				right:-28px;
				top: 6px;
			}
			#uploadTip{
				float:left;
				line-height: 34px;
			}
		</style>
		
		<script type="text/javascript">
			function showUploadify(varName){
				fileVarName = varName;
				$('#file').uploadify({
			        'formData': {
			        		//POST数据
			            '<?php echo session_name();?>' : '<?php echo session_id();?>',
			        },
			        'fileTypeDesc' : '上传文件',
			        'fileTypeExts' : '<?php echo $set['filetype'];?>',
			        'swf'      : 'http://127.0.0.1/vancl/Static/uploadify/uploadify.swf',
			        'uploader' : '<?php echo U("ajaxUpload");?>',
			        'buttonText':'选择文件',
			        'fileSizeLimit' : '2000KB',
			        'uploadLimit' : 1,//上传文件数
			        'multi': false,
			        'width':65,
			        'height':25,
			        'successTimeout':10,//等待服务器响应时间
			        'removeTimeout' : 0.2,//成功显示时间
			        'onUploadSuccess' : function(file, data, response) {
			            data=$.parseJSON(data);
			            var imageUrl = data.image?data.url:'http://127.0.0.1/vancl/Static/image/default.png';
			            var li="<li path='"+data.path+"' url='"+data.url+"'>" +
			            				"<img src='" + imageUrl + "' class='hd-w70 hd-h30'/>" +
			            				"<a id='a_del_li' href='javascript:;' title='删除'>" + 
			            					"<img src='http://127.0.0.1/vancl/Static/Admin/images/close1.png'/>" + 
			            				"</a>" + 
			            				"<input type='hidden' name='" + varName + "' value='" + data.path+"'/>" + 
			            			"</li>";
			            $("#uploadList ul").prepend(li);
			            $("#uploadDiv").html('');
			            $('#uploadTip').hide();
			        }
			    });
			}
			
			$(function() {
			    $('#a_del_li').live('click', function(){
			    		if (!confirm('确定要删除吗？')){
			    			return;
			    		}
			    		$("#uploadList ul li").remove();
			    		var str = "<input id='file' type='file' multiple='true'>";
			
			    		$("#uploadDiv").html(str);
			    		$('#uploadTip').show();
					showUploadify(fileVarName);	
			    });
			});
		</script>
		<script type="text/javascript">
			$(function(){
				showUploadify('logo');
			});
		</script>
		
		<script type="text/javascript">
			$(function() {
				$('form').validate({
					bname: {
						rule: {
							required: true,
							maxlen: 20
						},
						error: {
							required: "品牌名称不能为空",
							maxlen: '品牌名称不能超过20个字符'
						}
					},
					bsort: {
						rule: {
							num:'0,99999',
						},
						error: {
							num: '排序值范围在0～99999之间',
						}
					}
				})
			})
		</script>
	</head>

	<body>

		<div class="place">
			<span>位置：</span>
			<ul class="placeul">
				<li><a href="#">商品管理</a></li>
				<li><a href="#">品牌管理</a></li>
				<li><a href="#">添加品牌</a></li>
			</ul>
		</div>
		<form action="" method="POST">
			<div class="formbody">	
				<div class="formtitle"><span>添加品牌</span></div>	
				<ul class="forminfo">
					<li>
						<label>品牌名称</label>
						<input name="bname" type="text" class="dfinput" />
					</li>
					<li>
						<label>品牌LOGO</label>						
						<div lab="uploadFile" style="float:left">
							<div id="uploadDiv">
				            		<input id="file" type="file" multiple="true">
				            		
				            </div>
				            <div id="uploadList">            		
				                <ul>                		
				                </ul>
				            </div>
				            <div style="clear: both;"></div>
				        </div>	
				        <div id="uploadTip">
				        		<i>类型: *.jpg,*.png 大小: 2000KB 数量: 1</i>
				        </div>
					</li>
					<li>
						<label>是否热门</label>
						<cite>
				    			<input name="ishot" type="radio" value="0" checked="checked" />&nbsp;否&nbsp;&nbsp;&nbsp;&nbsp;
				    			<input name="ishot" type="radio" value="1" />&nbsp;是
				    		</cite>
					</li>
					<li>
						<label>排序</label>
						<input name="bsort" type="text" class="dfinput" value="0"/>
					</li>
					<li>
						<label>&nbsp;</label>
						<input name="" type="submit" class="btn" value="确认添加" />
					</li>
				</ul>	
			</div>
		</form>
	</body>

</html>